﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.Data;
using System.Data.SqlClient;

namespace WebApplication1.Pages.Home
{
    public partial class Cadequipamentos : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            lblsessao.Text = Session["id"].ToString();

            int z = 0;
            String conexString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["wallet"].ConnectionString;
            System.Data.SqlClient.SqlConnection conexao = new System.Data.SqlClient.SqlConnection(conexString);
            System.Data.SqlClient.SqlCommand comando = new System.Data.SqlClient.SqlCommand();
            comando.Connection = conexao;
            comando.CommandType = System.Data.CommandType.Text;
            comando.CommandText = "select * from potencia";
            conexao.Open();
            SqlDataReader dr = comando.ExecuteReader();

            ArrayList alArray = new ArrayList();

            while (dr.Read())
            {

                z = z + 1;
                DropDownList1.Items.Add(Convert.ToString(dr["nome_equip"]));

            }


            dr.Close();
            conexao.Close();





        }

        protected void btnasercadastrado_Click(object sender, EventArgs e)
        {
            //if (IsPostBack)
            //{
            //    //if (btnasercadastrado != null)
            //    //{
            //    //    Response.Write("botao a ser cadastrado pressionado");
            //    //    DropDownList2.Items.Add(DropDownList1.SelectedValue);
            //    //    DropDownList1.Items.Remove(DropDownList1.SelectedValue);

            //    //}




            //}



            if (DropDownList1.SelectedValue != null)
            {
                ltbaserretirado.Items.Add(DropDownList1.SelectedValue);
                UpdatePanel1.Update();
            }














            //else if ((bntaserretirado != null)&&(btnasercadastrado==null))
            //{
            //    Response.Write("botao a ser retirado pressionado");
            //    DropDownList2.Items.Remove(DropDownList2.SelectedValue);

            //}






        }

        protected void bntaserretirado_Click(object sender, EventArgs e)
        {
            if (ltbaserretirado.SelectedValue != null)
            {
                ltbaserretirado.Items.Remove(ltbaserretirado.SelectedValue);


            }



        }
    }
}